<?php

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::group(['namespace'=>'Wechat', 'prefix' => 'wechat', 'middleware' => ['ao']], function (){
    Route::any('/server', 'ServerController@server');
    Route::get('/menu/set', 'ServerController@setMenu');
    Route::get('/js/sdk', 'ServerController@getJsSdk');
    Route::get('/login', 'ServerController@login');
});

Route::group(['namespace'=>'Tool', 'prefix' => 'tool'], function (){
    Route::get('/district', 'AreaController@getArea');
    Route::get('/district/init', 'AreaController@getAreaInit');

    Route::post('/sms/check-code', 'SmsController@checkCode');
});

Route::group(['namespace'=>'Api', 'middleware' => ['ao']], function (){

    Route::post('/pay/wechat', 'OrderController@wechatPay');

    Route::group(['prefix' => 'wechat'], function (){
        Route::get('/callback-login', 'UserController@weixinCallback');
        Route::post('/mini-login', 'UserController@miniLogin');
        Route::get('/mini-authlogin', 'UserController@miniAuthLogin');
    });

    Route::group(['prefix' => 'user', 'middleware' => ['ApiAuth']], function (){
        Route::get('/my', 'UserController@my');
        Route::get('/address', 'UserController@getUserAddress');
        Route::get('/address/info/{id}', 'UserController@getUserAddressInfo');
        Route::post('/address/add', 'UserController@addUserAddress');
        Route::post('/address/update', 'UserController@updateUserAddress');
        Route::post('/bind/mobile', 'UserController@bindMobile');
        Route::post('/sign-in', 'UserController@signIn');
    });

    Route::group(['prefix' => 'activity', 'middleware' => ['ApiAuth']], function (){
        Route::get('/eat-every-day/goods', 'ActivityController@getEatEveryDayGoods');
        Route::get('/eat-every-day/rand', 'ActivityController@eatEveryDayRand');
        Route::get('/banner', 'ActivityController@getBanner');
    });

    Route::group(['prefix' => 'goods', 'middleware' => ['ApiAuth']], function (){
        Route::get('list', 'GoodsController@getGoods');
        Route::get('info/{id}', 'GoodsController@getGoodsInfo');
    });

    Route::group(['prefix' => 'order','middleware' => ['ApiAuth']], function (){
        Route::get('/my', 'OrderController@getMyOrder');
        Route::get('/cart', 'OrderController@cart');
        Route::post('/cart/update', 'OrderController@updateCart');
        Route::post('/create', 'OrderController@createOrder');
        Route::post('/buy-now', 'OrderController@buyNow');
        Route::get('/detail/{orderId}', 'OrderController@getOrderDetail');
        Route::post('/address/update', 'OrderController@updateOrderAddress');
        Route::post('/prepay', 'OrderController@prePay');
    });
});
